package com.huabo.system.oracle.mapper;

import com.huabo.system.oracle.entity.Find;
import com.huabo.system.oracle.entity.TblOrganization;
import com.hbfk.util.PageInfo;
import com.huabo.system.oracle.entity.Tblyyprice;
import com.huabo.system.service.impl.SysConfig;


import java.math.BigDecimal;

public class TblyypriceMapperSqlConifg {
	
	
	public String selectListByPageInfo(PageInfo<Tblyyprice> pageInfo, Find find, BigDecimal orgid) {
		StringBuffer sqlSb = new StringBuffer("SELECT * FROM (SELECT BUDGET.*,ROWNUM RN FROM (SELECT * from TBL_YY_PRICE where COMPANYID = "+orgid);
		if(find!=null && find.getInterfacename()!=null && find.getInterfacename().length()>0){
			sqlSb.append(" AND INTERFACENAME = '" + find.getInterfacename() + "' ");
		}
		sqlSb.append(" ORDER BY PRICEID ) BUDGET WHERE rownum <= "+(pageInfo.getCurrentPage()*pageInfo.getPageSize())+" ) WHERE RN > "+pageInfo.getCurrentRecord());
		String sql = sqlSb.toString();
		return sql;
	}
	
	public String selectCountByPageInfo(PageInfo<Tblyyprice> pageInfo, Find find, BigDecimal orgid) {
		String sqlCount="select count(*) from TBL_YY_PRICE where COMPANYID="+orgid;
		if(find!=null && find.getInterfacename()!=null && find.getInterfacename().length()>0){
			sqlCount+=" and  INTERFACENAME ='"+find.getInterfacename()+"' ";
		}
		sqlCount+=" order by PRICEID ";
		return sqlCount;
	}
	
	public String selectRepearBudgetName(String budgetname, BigDecimal orgid, String budgetId) {
		String sql = "SELECT COUNT(0) FROM TBL_CYHW_PROJECTBUDGET WHERE BUDGETNAME ='"+budgetname+"' AND ORGID = '"+orgid+"'";
		if(budgetId != null) {
			sql += " AND BUDGETID != "+budgetId;
		}
		return sql;
	}
	

	
}
